package com.woniuxy02;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

class Ccc {
}

class Ddd extends Ccc {
}

public class Test03 {
    public static void main(String[] args) {
//        Ccc ccc = new Ccc();
//        Ddd ddd = new Ddd();
        Ccc ccc = new Ccc();
        Ddd ddd = new Ddd();
        ccc = ddd;
        System.out.println(ccc instanceof Ccc);
        System.out.println(ccc instanceof Ddd);
        System.out.println(ddd instanceof Ccc);
        System.out.println(ddd instanceof Ddd);
        String str1 = "ab";
        String str2 = "ab中文";
        System.out.println(Arrays.toString(str1.getBytes()));
    }

    private static void test03() {
        //向下转型，假转型:
        Ccc ccc = new Ccc();
        Ddd ddd = new Ddd();
        ccc = ddd;
        ddd = (Ddd) ccc;
    }

    private static void test02() {
        Ccc ccc = new Ccc();
        Ddd ddd = new Ddd();
        //向下转型，真转型:编译报错，强制类型转换，允许时报错
        ddd = (Ddd) ccc;
    }

    private static void test01() {
        Ccc ccc = new Ccc();
        Ddd ddd = new Ddd();
        //向上转型 OK
        ccc = ddd;
    }
}
